﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using OpenMinded.BLL;
using OpenMinded.Model;
public partial class login : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btnOK_Click(object sender, EventArgs e)
    {
        if (CheckEmpty())
        {
            OpenMinded.Model.Users outUser;
            int errorNo;
            OpenMinded.BLL.Users user =  new OpenMinded.BLL.Users();
            bool isLogin = user.LoginIn(txtUserName.Value.Trim(), txtPassword.Value.Trim(), out outUser, out errorNo);
            if (isLogin)
            {
                Response.Redirect("main/index.aspx");
            }
            else if (errorNo == 1)
            {
                Response.Write("用户名不存在");
            }
            else if (errorNo == 2)
            {
                Response.Write("密码不正确");
            }
        }
    }
    private bool CheckEmpty()
    {
        bool isEmpty = true;
        if (string.IsNullOrEmpty(txtUserName.Value.Trim()))
        {
            isEmpty = false;
        }
        if (string.IsNullOrEmpty(txtPassword.Value.Trim()))
        {
            isEmpty = false;
        }
        return isEmpty;
    }
}